package com.stefanini.pe.bbva.mbl.in.dao;

import java.math.BigDecimal;import org.apache.log4j.Logger;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.stefanini.pe.bbva.mbl.carga.in.to.CargaConfig;
import com.stefanini.pe.bbva.mbl.in.dao.iface.CargaConfigDAO;

public class CargaConfigDAOImpl extends SqlMapClientDaoSupport implements CargaConfigDAO {
	private static final Logger logger = Logger.getLogger(CargaConfigDAOImpl.class);
	
    public CargaConfigDAOImpl() {
        super();
    }

    public int deleteByPrimaryKey(BigDecimal codCarga) {    	
        CargaConfig key = new CargaConfig();
        int rows = 0;
        
        logger.info("Inicio");
        
        key.setCodCarga(codCarga);
        rows = getSqlMapClientTemplate().delete("CARGA_CONFIG.ibatorgenerated_deleteByPrimaryKey", key);
        
        logger.info("Fin");
        
        return rows;
    }

    public void insert(CargaConfig record) {
    	logger.info("Inicio");
    	
        getSqlMapClientTemplate().insert("CARGA_CONFIG.ibatorgenerated_insert", record);
        
        logger.info("Fin");
    }

    public void insertSelective(CargaConfig record) {
    	logger.info("Inicio");
    	
        getSqlMapClientTemplate().insert("CARGA_CONFIG.ibatorgenerated_insertSelective", record);
        
        logger.info("Fin");
    }

    public CargaConfig selectByPrimaryKey(BigDecimal codCarga) {
        CargaConfig key = new CargaConfig();
        CargaConfig record = null;
        
        logger.info("Inicio");
        
        key.setCodCarga(codCarga);
        record = (CargaConfig) getSqlMapClientTemplate().queryForObject("CARGA_CONFIG.ibatorgenerated_selectByPrimaryKey", key);
        
        logger.info("Fin");
        
        return record;
    }

    public int updateByPrimaryKeySelective(CargaConfig record) {
        int rows = 0;
        
        logger.info("Inicio");
        
        rows = getSqlMapClientTemplate().update("CARGA_CONFIG.ibatorgenerated_updateByPrimaryKeySelective", record);
        
        logger.info("Fin");
        
        return rows;
    }

    public int updateByPrimaryKey(CargaConfig record) {
        int rows = 0;
        
        logger.info("Inicio");
        
        rows = getSqlMapClientTemplate().update("CARGA_CONFIG.ibatorgenerated_updateByPrimaryKey", record);
        
        logger.info("Fin");
        
        return rows;
    }
    
    public int selectSequence() {
    	int secuencia = 0;
    	
    	logger.info("Inicio");
    	
    	secuencia = Integer.parseInt((String)getSqlMapClientTemplate().queryForObject("CARGA_CONFIG.generated_llavePrimaria",""));
    	
    	logger.info("Fin");
    	
		return secuencia;
	}

	public List selectAll() {
		List records = null;
		
		logger.info("Inicio");
		
		records = getSqlMapClientTemplate().queryForList("CARGA_CONFIG.ibatorgenerated_selectAll", null);
		
		logger.info("Fin");
		
        return records;
	}	

}